package com.ncr.travel.appmgr.service.rest;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

public class ApplicationManagerRestClient {

	private static final String testUrl = "http://localhost:8080/application-manager-service";

	public static void main(String[] args) throws Exception {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/rest-integration-test.xml");
		context.start();

		RestTemplate restTemplate = context.getBean("restTemplate", RestTemplate.class);

		// Show json for Products
		// ResponseEntity<String> productResponse =
		// restTemplate.getForEntity(testUrl + "/products?userName=mark",
		// String.class);
		// System.out.println("Product response body = '" +
		// productResponse.getBody() + "'");

		// Show json for Screen Configuration
		ResponseEntity<String> configResponse = restTemplate.getForEntity(testUrl + "/config/KIOSK_CHECKIN/BaseCheckInApp&SelectPassenger&AddMileagePlan", String.class);
		System.out.println("Screen config response body = '" + configResponse.getBody() + "'");

		// Show json for Rules
		ResponseEntity<String> rulesResponse = restTemplate.getForEntity(testUrl + "/rules?screenName=AddMileagePlan", String.class);
		System.out.println("AddMileagePlan rules response body = '" + rulesResponse.getBody() + "'");
		rulesResponse = restTemplate.getForEntity(testUrl + "/rules?screenName=SpecialServiceRequestsCode", String.class);
		System.out.println("SpecialServiceRequestsCode rules response body = '" + rulesResponse.getBody() + "'");
		rulesResponse = restTemplate.getForEntity(testUrl + "/rules?screenName=Offer", String.class);
		System.out.println("Offer rules response body = '" + rulesResponse.getBody() + "'");
		context.stop();
	}

}
